package com.liuqi.openai.data.document;

import static java.util.Arrays.asList;

/**
 * 文档类型
 *
 * @author liuqi
 * @date 2025/8/7
 **/
public enum DocumentType {

    TXT(".txt"),

    UNKNOWN;

    private final Iterable<String> suffix;

    DocumentType(String... suffix) {
        this.suffix = asList(suffix);
    }

    public static DocumentType of(String name) {
        for (DocumentType documentType : values()) {
            for (String supportedExtension : documentType.suffix) {
                if (name.toLowerCase().endsWith(supportedExtension)) {
                    return documentType;
                }
            }
        }
        return UNKNOWN;
    }

}
